
define(function (require, exports, module) {
	var C = require("resource/js/config/const.js");
	using(["validatebox"],function(){
		$.extend($.fn.validatebox.defaults.rules, {    
		    cardNo: {    
		        validator: function(value){    
		        	var rf = require("resource/js/component/IdCard-Validate.js");
		        	var flag = rf.IdCardValidate(value);
		        	return flag;
		        	//return /^\d{18}$|^\d{15}xxx$/.test(value);
		        },    
		        message: C.MESSAGE.IDCARD//'身份证号不合法.'   
		    },
		    code: {    
				validator: function(value){    
					return /^[\w|\d]{4,18}$/.test(value);    
				},
				message: '编码不合法.格式4-18个数字或字母'
			},
			phone: {    
				validator: function(value){    
					return /^0[\d]{2,3}[-|| ]\d{7,8}$/.test(value);
				},
				message: '电话应该是区号-电话号码'
			},
			mobile: {    
				validator: function(value){    
					return /^0?1[3|4|5|7|8][0-9]\d{8}$/.test(value);    
				},    
				message: '手机号码不合法'
			},
			telNum:{ //既验证手机号，又验证座机号
			      validator: function(value, param){ 
			          return /(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$)|(^((\d3)|(\d{3}\-))?(1[358]\d{9})$)/.test(value);
			         },    
			         message: '请输入正确的号码' 
			    },
			fax: {    
				validator: function(value){    
					return (/^(([0\+]\d{2,3}-)?(0\d{2,3}\-)?([2-9]\d{6,7})+(\-\d{1,4})?|(?:13\d|15[012356789]|18[0256789]|147)-?\d{5}(\d{3}|\*{3}))?$/.test(value));    
				},    
				message: '企业传真不合法'
			},
			zipCode: {    
				validator: function(value){    
					return /^[1-9]\d{5}$/.test(value);    
				},    
				message: '邮编不合法'
			},
			uemail:{
				validator:function(value){
					return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/.test(value);
				},
				message:'邮箱不合法'
			},
			password: {    
				validator: function(value){    
					return /^[\w|\d]{6,18}$/.test(value);    
				},    
				message: '密码不合法，请输入6-18位数字或字母'
			}
			,equalTo: {
		        validator:function(value,param){
		            return $(param[0]).val() == value;
		        },
		        message:'两次输入的密码不匹配'
		    }
			,number: {
		        validator:function(value){
		            //return !isNaN(value);
		        	return /^(-)?\d+(\.\d+)?$/.test(value)
		        },
		        message:'请输入有效数字'
		    },
		    maxlength:{
		    	validator:function(value,param){
		            return value.length<=param;
		        },
		        message:"输入内容长度必须介于1和{0}之间"
		    },
		    realmaxlength:{
		    	validator:function(value,param){
		    		var strlen = 0;
		    		for(var lenthIndex=0;lenthIndex<value.length;lenthIndex++){
		    			if(value.charCodeAt(lenthIndex) > 255){// 如果是汉字，则字符串长度加2
		    				strlen += 2;
		    			}else{
		    				strlen += 1;
		    			}
		    		}
		    		return strlen<param;
		    	},
		    	message:"输入长度超出字符长度限制！"
		    },
			combobox:{
				validator:function(value){
					value = $(this).next().val();
					if(value == '' || value == null || value == '请选择') return false;
					return true;
				},
				message:'请选择有效选项'
			},
			moreThan:{
				validator:function(value,param){
					if($(param[0]).attr('class').indexOf("easyui-datetimebox")>-1){
						return $(param[0]).datetimebox("getValue")<value;
					}else if($(param[0]).attr('class').indexOf("easyui-datebox")>-1){
						return $(param[0]).datebox("getValue")<value;
					}else if($(param[0]).attr('class').indexOf("easyui-numberbox")>-1){
						return $(param[0]).numberbox("getValue")<value;
					}
		            return true;
		        },
		        message:'结束时间不能小于开始时间'
			}
			,url:{
				validator:function(value){
					return /(http(s)?:\/\/)?(www\.)?[\w-]+\.\w{2,4}(\/)?$/.test(value);
		        },
		        message:'网址不合法'
			},
			vitoEmail: {
				validator: function(value) {
					return /^[a-z0-9]{2,20}$/.test(value);
				},
				message:'小写字母、数字或者小写字母数字的组合，长度(2~20)'
			},
			max:{
				validator: function(value,param) {
					return value <= param[0];
				},
				message:'输入最大值为{0}'
			},
			absNumber:{
				validator: function(value) {
					return value >= 0;
				},
				message:'输入值为非负数'
			},
			posNumber:{
				validator: function(value) {
					return value > 0;
				},
				message:'请输入正数'
			}
		});
	});
});